#include "shm.hpp"
#include "fifo.hpp"

int main()
{
    // 创建共享内存
    Shm shm(PATH, PROJID, CREATER);
    shm.CreateOrGet();
    // 绑定共享内存
    char *ptr = (char *)shm.Attach();

    // 创建管道文件，模拟同步
    Pipe fifo(PATH, FILE_NAME);
    PipeOper oper(PATH, FILE_NAME);
    oper.OpenForRead();
    // 读取内容
    while (true)
    {
        if (oper.Wait())
        {
            // std::cout<<ptr<<std::endl;
            printf("%s\n", ptr);
        }
        else
        {
            break;
        }

        sleep(1);
    }
    oper.Close();

    return 0;
}